


local role_mode = fk.CreateGameMode{
  name = "all_wuming_mode", -- just to let it at the top of list
  minPlayer = 2,
  maxPlayer = 8,
  main_mode = "role_mode",
  logic = function()
    local l = GameLogic:subclass("all_wuming_mode_logic")
    function l:run()
      self.room.settings.enableDeputy = false
      GameLogic.run(self)
    end

    function l:chooseGenerals()
      local room = self.room---@type Room
      local players = room.players

      local lord = room:getLord()
      if not lord then
        local temp = room.players[1]
        temp.role = "lord"
        lord =  temp
      end
      room:setCurrent(lord)
      local generals = {"wuming", "ba__wuming","er__wuming"}
      
      local req = Request:new(players, "AskForGeneral")
      for i, p in ipairs(players) do
        local arg = table.slice(generals)
        req:setData(p, { arg, 1 })
        req:setDefaultReply(p, table.random(arg, 1))
      end


      for _, p in ipairs(players) do
        local result = req:getResult(p)
        local general = result[1]
        if general ~= "wuming" and general ~= "ba__wuming" and general ~= "er__wuming" then
          general = "wuming"
        end
        room:findGeneral(general)
        room:prepareGeneral(p, general, "")
      end
      room:askToChooseKingdom(players)

      room:broadcastProperty(lord, "kingdom")


      local lord_skills = Fk.generals[lord.general]:getSkillNameList(true)
      for _, sname in ipairs(lord_skills) do
        local skill = Fk.skills[sname]
        if not skill:hasTag(Skill.AttachedKingdom) or table.contains(skill:getSkeleton().attached_kingdom, lord.kingdom) then
          room:doBroadcastNotify("AddSkill", { lord.id, sname })
        end
      end


    end

    return l
  end,
  surrender_func = Fk.game_modes["aaa_role_mode"].surrenderFunc
}

Fk:loadTranslationTable{
  ["all_wuming_mode"] = "无名任选",
  [":all_wuming_mode"] = "就是禁用了副将且可以任选一种无名的身份模式。若选择了非无名的将，则更换成无名。",
  ["#all_wuming_rule"] = "无名任选规则",
}

return role_mode
